<!-- 顶部组件 -->
<template>
  <div class="header_nav_module">
    <van-nav-bar>
      <template #left>
        <div class="left_module">
          <slot name="nav-left" />
          <van-icon v-if="judgeBrowser().isMobile" name="cross" size="18px" color="rgb(24, 24, 24)" @click="closeWindow()" />
        </div>
      </template>
      <template #title>
        <div v-if="title">{{ title }}</div>
        <slot name="nav-title" />
      </template>
      <template #right>
        <slot name="nav-right" />
      </template>
    </van-nav-bar>
  </div>
</template>

<script>
import { judgeBrowser } from '@/utils/index.js'
import { inDingTalk, closeWindow } from '@/utils/dd'
import { NavBar } from 'vant'
export default {
  components: {
    [NavBar.name]: NavBar
  },
  props: {
    title: {
      type: String,
      default: ''
    },
    close: {
      type: Boolean,
      default: true
    }
  },
  data() {
    return {}
  },
  methods: {
    judgeBrowser,
    closeWindow() {
      if (inDingTalk()) {
        closeWindow()
      } else {
        const win = window.open('about:blank', '_self')
        win.close()
      }
    }
  }
}
</script>

<style lang="less" scoped>
.header_nav_module {
  width: 100%;
  position: absolute;
  left: 0;
  top: 0;
  z-index: 2;
}
.left_module {
  display: flex;
  justify-content: flex-start;
  align-items: center;
}
</style>
